package com.ruoyi.system.utils;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

// 创建自定义反序列化器
public class NullStringDeserializer implements ObjectDeserializer {
    @Override
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        Object obj = parser.parse();
        if (obj instanceof String && "null".equalsIgnoreCase((String) obj)) {
            return (T) "";
        }
        return (T) obj;
    }

    @Override
    public int getFastMatchToken() {
        return 0;
    }
}